import Mock from 'mockjs'

const lots = Mock.mock({
  'list|20': [{
    'id|+1': 1,
    name: '@ctitle(10, 20)',
    num: '@natural(0, 990)',
    time: [1537416000000, 1537488000000]
  }],
  total: 88
})

const lotInfo = Mock.mock({
  id: 1,
  name: '古龙会专场',
  state: '@natural(1, 1)',
  // [总件数，成交，流拍，未拍]
  num: [342, 67, 34, 128],
  deal: ['34430000', '82.48%'],
  'goods|50-100':[{
    'id|+1': 1,
    'lot|+1': 1,
    name: '@ctitle(5, 20)',
    'spec': [{ attr: '尺寸', val: 'H:7.8 D:9.6' }],
    cover: 'https://placeimg.com/320/200/nature/sepia',
    'state|+1': [1, 0, 1, 2, 2],
    curr: '@natural(100000000, 1000000000)',
    'curr_buyer|1': [0, '', '@natural(111, 999)'],
    start: '@natural(0, 10000)',
    'final|+1': ['', '', '10000', '流拍']
  }],
  'recent|3': [{
    lot: '@natural(111, 999)',
    'final|1': ['流拍', '10000'],
    'buyer_num|1': [0, '@natural(111, 999)'],
    'buyer_way|1': ['现场', '网络']
  }],
  bids: [{ num: 0, bid: '@natural(1000, 100000)' }],
  disRevoke: false,
  index: '@natural(0, 49)',
  livePush: {
    play: false,
    url: '',
    qr: ''
  }
})

const bidcoInfo = Mock.mock({
  name: '古龙会专场',
  goods:{
    'id|+1': 1,
    'lot|+1': 1,
    name: '@ctitle(5, 20)',
    cover: 'https://placeimg.com/320/200/nature/sepia',
    'state|+1': [1, 0, 1, 2, 2],
    curr: '@natural(100000000, 1000000000)',
    'spec': [{ attr: '尺寸', val: 'H:7.8 D:9.6' }],
    'curr_buyer|1': [0, '', '@natural(111, 999)', '大河国际拍卖公司'],
    start: '@natural(0, 10000)',
    'final|+1': ['', '', '10000', '流拍']
  },
  'recent|3': [{
    lot: '@natural(111, 999)',
    'final|1': ['流拍', '10000'],
    'buyer_num|1': [0, '@natural(111, 999)'],
    'buyer_way|1': ['现场', '网络']
  }],
  'bids|6': [
    { 'num|1': ['大河国际 拍卖公司拍卖公司', 0, '0', '234'], bid: '@natural(1000, 100000)' }
  ],
})

export default [
  {
    url: '/ctrl/getLots',
    type: 'get',
    response: config => {
      return {
        code: 200,
        data: lots
      }
    }
  },
  {
    url: '/ctrl/getLotData',
    type: 'get',
    response: config => {
      return {
        code: 200,
        data: lotInfo
      }
    }
  },
  {
    url: '/ctrl/setLotState',
    type: 'post',
    response: config => {
      const { id, state } = config.body
      return {
        code: 200,
        data: { id: Number(id), state: Number(state) }
      }
    }
  },
  {
    url: '/ctrl/setGoodsState',
    type: 'post',
    response: config => {
      const { id, op } = config.body
      const opMap = {
        start: 1,
        cancel: 0,
        pass: 2,
        deal: 2,
        re: 1
      }
      return {
        code: 200,
        data: {
          id: Number(id),
          'lot|+1': 1,
          name: '@ctitle(5, 20)',
          cover: 'https://placeimg.com/320/200/nature/sepia',
          state: opMap[op],
          curr: '@natural(0, 10000)',
          curr_buyer: op === 'start' || op === 'deal' ? 0 : '',
          start: '@natural(0, 10000)',
          final: op === 'deal' ? '@natural(100, 10000)' : op === 'pass' ? '流拍' : '',
          next_index: 2
        }
      }
    }
  },
  {
    url: '/ctrl/postLiveBid',
    type: 'post',
    response: config => {
      const { id, bid } = config.body
      return {
        code: 200,
        data: {},
        msg: '出价成功！'
      }
    }
  },
  {
    url: '/ctrl/revokeBid',
    type: 'post',
    response: config => {
      const { id } = config.body
      return {
        code: 200,
        data: {},
        msg: '撤回成功！'
      }
    }
  },
  {
    url: '/ctrl/setLivePush',
    type: 'post',
    response: config => {
      const { live } = config.body
      return {
        code: 200,
        data: {
          play: Boolean(Number(live)),
          qr: 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1587441635,1276314476&fm=26&gp=0.jpg',
          url: 'rtmp://110284.livepush.myqcloud.com/live/demo?txSecret=9c1242816817bda62189a659e526db25&txTime=5F59DFA0'
        }
      }
    }
  },
  {
    url: '/ctrl/getScreenLots',
    type: 'get',
    response: config => {
      return {
        code: 200,
        'data|0-20': [{
          'id|+1': 1,
          name: '@ctitle(10, 20)'
        }]
      }
    }
  },
  {
    url: '/ctrl/getScreenData',
    type: 'get',
    response: config => {
      return {
        code: 200,
        data: {
          name: lotInfo.name,
          num: lotInfo.num,
          curr: {
            id: 1,
            lot: 1012,
            name: '@ctitle(5, 18)',
            cover: 'http://rykauction.com/static/img/poster01.54835a0c.jpg',
            curr: '@natural(10000000, 1000000000)',
            start: '100000',
            'spec|2': [{ attr: '尺寸', val: 'H:7.8 D:9.6' }],
          },
          'bids|3': [{ num: '212', way: '网络', bid: '@natural(10000, 10000000)' }],
          last: {
            lot: 2342,
            state: '成交',
            bid: 180000
          },
          h5Qr: 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1587441635,1276314476&fm=26&gp=0.jpg'
        }
      }
    }
  },
  {
    url: '/ctrl/getBidcoCurr',
    type: 'get',
    response: config => {
      return {
        code: 200,
        data: bidcoInfo
      }
    }
  },
  {
    url: '/ctrl/postCoBid',
    type: 'post',
    response: config => {
      const { id, bid } = config.body
      return {
        code: 200,
        data: {},
        msg: '已提交，等待出价审核！'
      }
    }
  },
  {
    url: '/ctrl/setLiveNum',
    type: 'post',
    response: config => {
      return {
        code: 200
      }
    }
  },
  {
    url: '/ctrl/getBidnetCurr',
    type: 'get',
    response: config => {
      return {
        code: 200,
        data: bidcoInfo
      }
    }
  },
  {
    url: '/ctrl/passNetBid',
    type: 'post',
    response: config => {
      return {
        code: 200
      }
    }
  },
]